-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ghidra: Basic Block Feature Extraction #1637
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great progress @colton-gabertan ! It's cool to see you digging deeper into Ghidra's scripting API! I've left comments for your review.
def get_printable_len(op: ghidra.program.model.scalar.Scalar) -> int: | ||
"""Return string length if all operand bytes are ascii or utf16-le printable""" | ||
op_bit_len = op.bitLength() | ||
op_val = op.getValue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are dealing with printable characters, should we be using getUnsignedValue
here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want it to ever return a NoneType, and the &'s
handle the conversion to an unsigned int. I was thinking that the NoneTypes would cause crashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense - I'm not seeing anywhere in Ghidra's documentation where getUnsignedValue
may return None
? Did you find this was the case during testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work @colton-gabertan ! LGTM 🚀
def get_printable_len(op: ghidra.program.model.scalar.Scalar) -> int: | ||
"""Return string length if all operand bytes are ascii or utf16-le printable""" | ||
op_bit_len = op.bitLength() | ||
op_val = op.getValue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense - I'm not seeing anywhere in Ghidra's documentation where getUnsignedValue
may return None
? Did you find this was the case during testing?
Checklist
Implements #1510 - Ghidra: Basic Block Feature Extraction